<template>
  <div class="echarts">
    <div ref="divs" class="divs"></div>
  </div>
</template>
          
  <script>
import * as echarts from "echarts/core";
import { GridComponent } from "echarts/components";
import { LineChart } from "echarts/charts";
import { UniversalTransition } from "echarts/features";
import { CanvasRenderer } from "echarts/renderers";
echarts.use([GridComponent, LineChart, CanvasRenderer, UniversalTransition]);
export default {
  name: "Echarts",
  props: {
    x: Array,
    y: Array,
  },
  data() {
    return {
      option: {
        xAxis: {
          type: "category",
          data: this.x,
          axisTick: {
            show: false,
            alignWithLabel: true,
          },
          axisLabel: {
            textStyle: {
              color: "#000000",
            },
          },
          axisLine: {
            show: true, //这里的show用于设置是否显示y轴那一条线 默认为true
            lineStyle: {
              color: "#cccccc",
              width: 2, //轴线的粗细 我写的是2 最小为0，值为0的时候线隐藏
            },
          },
        },
        yAxis: {
          type: "value",
          min: 0, //y轴的最小值
          max: 500, //y轴最大值
          interval: 100, //值之间的间隔
          axisTick: {
            show: false,
          },
          axisLabel: {
            textStyle: {
              color: "#000000",
            },
          },
          axisLine: {
            show: true, //这里的show用于设置是否显示y轴那一条线 默认为true
            lineStyle: {
              color: "#cccccc",
              width: 2, //轴线的粗细 我写的是2 最小为0，值为0的时候线隐藏
            },
          },
        },
        series: [
          {
            symbol: "none",
            data: this.y,
            type: "line",
            lineStyle: {
              normal: {
                color: "#666fe6",
                width: 3,
                shadowOffsetX: 4, // 折线的X偏移
                shadowOffsetY: 4, // 折线的Y偏移
                shadowBlur: 10, // 折线模糊
              },
            },
          },
        ],
      },
    };
  },
  mounted() {
    this.myChart = echarts.init(this.$refs.divs);
    this.option && this.myChart.setOption(this.option);
  },
};
</script>
          
  <style scoped lang="scss">
.echarts {
  height: 100%;
  .divs {
    width: 100%;
    height: 100%;
  }
}
</style>